<?php
	//if there are already updated files
	if (!empty($this->data[updatedFiles]))
	{
		echo '<span class = "success">'.LANG_UPDATED_FILES.':</span><ul>';
		
		foreach ($this->data[updatedFiles] as $updatedFile)
		{
			echo "<li style = 'list-style-type: disc'>$updatedFile</li>";
		}
		
		echo "</ul><br />";
	}

	$this->helpers->htmlx->form('');
	echo "<table class = 'grid'>
			<tr class = 'gridHeader'>
				<td class = 'gridHeader'>&nbsp;</td>
				<td class = 'gridHeader'>".LANG_PATH_TO_FILE."</td>
				<td class = 'gridHeader'>".LANG_STATUS."</td>
				<td class = 'gridHeader'>".LANG_LAST_MODIFIED." (".LANG_REMOTE_FILE.")</td>
				<td class = 'gridHeader'>".LANG_LAST_MODIFIED." (".LANG_LOCAL_FILE.")</td>
				<td class = 'gridHeader'>".LANG_ACTION."</td>
			</tr>";
	foreach ($this->data[updates] as $title => $updates) 
	{
		$folderPath = pathinfo($updates[0][path]);
		
		echo "
			<tr class = 'gridRow' style = 'text-align: center; font-weight: bold;'>
				<td colspan = '6' class = 'gridCell'>".ucfirst($title)."
					<a href = '' onclick = 'SendValues(\"/systemupdater/removebackups/?dir=$folderPath[dirname]\"); this.style.display = \"none\"; return false;'> (".LANG_REMOVE_BACKUPS.")</a>
				</td>
			</tr>";
		foreach ($updates as $key=>$update)
		{
			echo "<tr>";
			switch ($update[status])
			{
				case '=':
					$color = 'black';
					$checked = false;
					$status = LANG_FILE_NOT_MODIFIED;
					break;
				case '>':
					$color = 'blue';
					$checked = true;
					$status = LANG_REMOTE_FILE_IS_NEWER;
					break;
				case '<':
					$color = 'red';
					$checked = false;
					$status = LANG_REMOTE_FILE_IS_OLDER;
					break;
				case '-':
					$color = 'green';
					$checked = true;
					$status = LANG_FILE_NOT_PRESENT;
					break;
			}
			
			echo "<td class = 'gridCell' style = 'width: 18px;'>";
				$this->helpers->htmlx->Checkbox("files[$update[path]]", 1, $checked);
			echo "</td>";
			echo "<td class = 'gridCell' style = 'color: $color'>";
				echo $update[path];
			echo "</td>";
			echo "<td class = 'gridCell' style = 'color: $color'>";
				echo $status;
			echo "</td>";
			echo "<td class = 'gridCell'>";
				echo (!empty($update[remoteTime])) ? date("Y-m-d H:i:s", $update[remoteTime]) : '-';
			echo "</td>";
			echo "<td class = 'gridCell'>";
				echo (!empty($update[localTime])) ? date("Y-m-d H:i:s", $update[localTime]) : '-';
			echo "</td>";
			echo "<td class = 'gridCell'>";
				$this->helpers->htmlx->Link("/spanel/viewsource/index/?path_to_file=.".$update[path], LANG_VIEW, "style = '' target = '_blank'");
			echo "</td>";
			echo "</tr>";
		}
	}
	echo "</table>";
	
	$this->helpers->htmlx->Submit('submit1', LANG_UPDATE, "style = 'border: 1px solid gray; cursor: pointer; margin-top: 10px; font-size: 11px; font-family: verdana'");
	
	echo "</form>";
?>